import { CONFIG_NAMES } from "../inversify/CONFIG_NAMES";
import type { IConfigService } from "../interface/IConfigService";
import { IGuiService } from "../interface/IGuiService";
import { BaseService } from "./BaseService";
import * as lil from "lil-gui";
import { myContainer } from "../inversify/inversify.config";
import { ConfigService } from "../service/ConfigService";

export abstract class BaseGuiService
  extends BaseService
  implements IGuiService
{
  protected config: IConfigService;
  protected gui!: lil.GUI;
  constructor() {
    super();
    this.config = myContainer.get(ConfigService);
  }
  load(): Promise<void> {
    this.gui?.destroy();
    this.gui = new lil.GUI();
    if (this.config.get(CONFIG_NAMES.SHOW_GUI)) {
      this.show();
    } else {
      this.hide();
    }
    return Promise.resolve();
  }
  start(): Promise<void> {
    return Promise.resolve();
  }
  stop(): Promise<void> {
    return Promise.resolve();
  }
  unload(): Promise<void> {
    this.hide();
    this.gui?.destroy();
    return Promise.resolve();
  }

  abstract show(): void;
  abstract hide(): void;
}
